import { defineStore } from 'pinia';
import { store } from '@/store';
import { storage } from '@/utils/Storage';

export const useGlobalConfigStore = defineStore({
  id: 'app-global-config',
  state: () => {
    return {
      configGlobal: storage.get('configGlobal') ?? false,
    };
  },
  getters: {
    getConfigGlobal(): boolean {
      return this.configGlobal;
    },
  },
  actions: {
    setConfigGlobal(configGlobal: boolean) {
      storage.set('configGlobal', configGlobal);
      this.configGlobal = configGlobal;
    },
  },
});

export function useGlobalConfig() {
  return useGlobalConfigStore(store);
}
